var init=function function_name () {
	var options = {
		onFail: function(){
			alert( $myform.getInvalid().length +' invalid fields.' )
		},
		inputs: {
			'Company_logo1': {
				filters: 'required extension',
				data: { extension: ['png','jpg'] }
			},
			'Product_photo1': {
				filters: 'required extension',
				data: { extension: ['png','jpg'] }
			},
			'password': {
				filters: 'required pass',
			},
			'username': {
				filters: 'required username',
				data: {
				//ajax: { url:'validate.php' }
				}
			},
			'phone':{
				filters: 'required phone',
				data: {
				//ajax: { url:'validate.php' }
				}
			},
			'Product_title':{
				filters: 'required Product_title',
				data: {
				//ajax: { url:'validate.php' }
				}
			},
			'Product_description':{
				filters: 'required Product_description',
				data: {
					min: 1, max: 120
				}
			},
			'comments': {
				filters: 'min max',
				data: { min: 50, max: 200 }
			},
			'states': {
				filters: 'exclude',
				data: { exclude: ['default'] },
				errors : {
					exclude: '选择国籍.'
				}
			},
			'langs[]': {
				filters: 'min max',
				data: { min: 2, max: 3 },
				errors: {
					min: 'Check at least <strong>2</strong> options.',
					max: 'No more than <strong>3</strong> options allowed.'
				}
			}
		}
	};
	function _add(){
		//判断是切换语言还是添加
		$('body').removeClass('language');
		var uber=$('.product_list').length;
		options.inputs['Product_photo'+uber]={
				filters: 'required extension',
				data: { extension: ['png','jpg'] }
		}

		var $myform_add = $('.product_list').last().idealforms(options).data('idealforms');
		$myform.focusFirst();
		if ($('body').attr('lang')=="zh") {
			$('.la').eq(0).click();
		}else{
			// $('.la').eq(1).click();
		}
	}
	var number=$('.product_list').length;
	var new_number=number+1;
	var c='<div class="product_list"><div class="title"></div><div class="border_h"></div><div class="title font2 Product_Registration">Product Registration</div><div class="title"></div><div><p class="Product_title">Product title:</p><input class="Product_title" name="Product_title	'+new_number+'" data-ideal="required Product_title" placeholder="Product title" type="text"/></div><div><p class="Product_description">Product description (max 120words):</p><textarea class="h150" name="Product_description'+new_number+'" data-ideal="required Product_description"  autocomplete="off"></textarea></div><div><p class="Product_quantity">Product quantity:</p><input class=""  placeholder="Product quantity" name="Product_quantity'+new_number+'" type="text"/></div><div><p class="Product_price">Product price:</p><input type="text" name="Product_price'+new_number+'" class="Product_price" placeholder="Product price"/></div><div><p class="Choose_file">Choose file:</p><input id="photo" name="Product_photo'+new_number+'" data-ideal="required extension" class="Product_photo"  multiple type="file"/><p class="red_small Product_photo">*Product photo (150px1500px)</p></div><div><p class="Campaign_starting_date">Campaign starting date:</p><input name="Product'+new_number+'_date" class="datepicker" data-ideal="date" type="text" placeholder="MM/DD/YYYY"/></div></div>';
	var $myform = $('#my-form').idealforms(options).data('idealforms');
	$('#reset').click(function(){
		$myform.reset().fresh().focusFirst();
	});
	$('.add_Product').click(function(){
		$('.product_list:last').after(c);
		_add();
	});
	// $myform.focusFirst();
}
$(init);